package com.aaron.gesturehelper;

import android.content.Context;
import android.content.Intent;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;

public class SeekBarPreference extends Preference implements SeekBar.OnSeekBarChangeListener {

	public SeekBarPreference(Context context, AttributeSet attrs) {
		super(context, attrs);
		setLayoutResource(R.layout.myseekbar);
	}

	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
		persistInt(progress);
		Intent intent = new Intent(Contants.INTENT_CONFIGURATION_CHANGED);
		intent.putExtra(MyConfiguration.GESTUREAREA_EXPAND_TIME, true);
		getContext().sendBroadcast(intent);
	}

	public final void onStartTrackingTouch(SeekBar seekBar) {
	}

	public final void onStopTrackingTouch(SeekBar seekBar) {
	}

	protected final void onBindView(View view) {
		super.onBindView(view);
		
		SeekBar barView = (SeekBar) ((ViewGroup) view).findViewById(R.id.seekbar);
		barView.setOnSeekBarChangeListener(this);
		barView.setProgress(getPersistedInt(0));
	}
}